<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>欢迎来到我的网站</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }

        /* 导航栏样式 */
        nav {
            background-color: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            padding: 1rem 0;
            position: fixed;
            width: 100%;
            top: 0;
            z-index: 1000;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .nav-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            font-size: 1.5rem;
            font-weight: bold;
            color: #667eea;
            text-decoration: none;
        }

        .nav-links {
            display: flex;
            list-style: none;
        }

        .nav-links li {
            margin-left: 2rem;
        }

        .nav-links a {
            text-decoration: none;
            color: #333;
            font-weight: 500;
            transition: color 0.3s ease;
        }

        .nav-links a:hover {
            color: #667eea;
        }

        /* 主要内容区域 */
        .hero {
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            padding-top: 60px;
        }

        .hero-content {
            background: rgba(255, 255, 255, 0.95);
            padding: 3rem;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            max-width: 800px;
            backdrop-filter: blur(10px);
        }

        .hero h1 {
            font-size: 3rem;
            margin-bottom: 1rem;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .hero p {
            font-size: 1.2rem;
            margin-bottom: 2rem;
            color: #666;
        }

        .btn {
            display: inline-block;
            padding: 12px 30px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            text-decoration: none;
            border-radius: 50px;
            font-weight: bold;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            border: none;
            cursor: pointer;
            font-size: 1rem;
        }

        .btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
        }

        /* 特性区域 */
        .features {
            padding: 5rem 0;
            background-color: #f8f9fa;
        }

        .section-title {
            text-align: center;
            font-size: 2.5rem;
            margin-bottom: 3rem;
            color: #333;
        }

        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 2rem;
        }

        .feature-card {
            background: white;
            padding: 2rem;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
            text-align: center;
        }

        .feature-card:hover {
            transform: translateY(-10px);
        }

        .feature-icon {
            font-size: 3rem;
            margin-bottom: 1rem;
            color: #667eea;
        }

        .feature-card h3 {
            margin-bottom: 1rem;
            color: #333;
        }

        /* 页脚 */
        footer {
            background: #333;
            color: white;
            text-align: center;
            padding: 2rem 0;
        }

        /* 用户信息区域 */
        .user-info {
            position: absolute;
            top: 20px;
            right: 20px;
            background: rgba(255, 255, 255, 0.9);
            padding: 10px 20px;
            border-radius: 30px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            display: none;
        }

        .user-info span {
            margin-right: 15px;
            color: #333;
        }

        .logout-btn {
            background: #ff6b6b;
            color: white;
            border: none;
            padding: 5px 15px;
            border-radius: 15px;
            cursor: pointer;
            font-size: 0.9rem;
        }

        .logout-btn:hover {
            background: #ff5252;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .hero h1 {
                font-size: 2rem;
            }

            .hero-content {
                padding: 2rem;
                margin: 0 1rem;
            }

            .nav-links {
                display: none;
            }
        }
    </style>
</head>
<body>
    <!-- 用户信息 -->
    <div class="user-info" id="userInfo">
        <span>欢迎您，<span id="username"></span></span>
        <button class="logout-btn" onclick="logout()">退出登录</button>
    </div>

    <!-- 导航栏 -->
    <nav>
        <div class="container nav-container">
            <a href="#" class="logo">我的网站</a>
            <ul class="nav-links">
                <li><a href="#">首页</a></li>
                <li><a href="#features">功能</a></li>
                <li><a href="#">联系</a></li>
            </ul>
        </div>
    </nav>

    <!-- 主要内容 -->
    <section class="hero">
        <div class="container">
            <div class="hero-content">
                <h1>欢迎来到精美首页</h1>
                <p>这是一个现代化、响应式的网页设计，展示了我们的产品和服务。我们致力于为用户提供最好的体验。</p>
                <p>您已成功登录系统！</p>
            </div>
        </div>
    </section>

    <!-- 功能特性 -->
    <section class="features" id="features">
        <div class="container">
            <h2 class="section-title">我们的特色</h2>
            <div class="features-grid">
                <div class="feature-card">
                    <div class="feature-icon">🚀</div>
                    <h3>快速高效</h3>
                    <p>优化的系统架构确保您的操作流畅无阻，提供卓越的用户体验。</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">🔒</div>
                    <h3>安全可靠</h3>
                    <p>采用先进的安全技术保护您的数据和隐私，让您安心使用。</p>
                </div>
                <div class="feature-card">
                    <div class="feature-icon">📱</div>
                    <h3>响应式设计</h3>
                    <p>适配各种设备屏幕，在手机、平板和电脑上都能完美显示。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- 页脚 -->
    <footer>
        <div class="container">
            <p>&copy; 2025 我的网站. 保留所有权利。</p>
        </div>
    </footer>

    <script>
        // 页面加载完成后检查用户登录状态
        window.onload = function() {
            checkLoginStatus();
        };

        // 检查用户登录状态
        function checkLoginStatus() {
            // 发送请求检查会话中是否有用户信息
            fetch('/api/check-login')
                .then(response => response.json())
                .then(data => {
                    if (data.code === 1) {
                        // 用户已登录，显示用户信息
                        document.getElementById('userInfo').style.display = 'flex';
                        document.getElementById('username').textContent = data.data.username;
                    } else {
                        // 用户未登录，跳转到登录页面
                        window.location.href = '/login.html';
                    }
                })
                .catch(error => {
                    console.error('检查登录状态时出错:', error);
                    // 出错时也跳转到登录页面
                    window.location.href = '/login.html';
                });
        }

        // 退出登录
        function logout() {
            fetch('/logout', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .then(response => response.json())
            .then(data => {
                if (data.code === 1) {
                    // 退出成功，跳转到登录页面
                    window.location.href = '/login.html';
                } else {
                    alert('退出登录失败');
                }
            })
            .catch(error => {
                console.error('退出登录时出错:', error);
                alert('退出登录时出现错误');
            });
        }
    </script>
</body>
</html>